package com.bdd.Enum;

public enum DiscountsEnum {

    TENP_OFF("一折",0.1),
    TWENTYP_OFF("两折",0.2),
    THIRTY_OFF("三折",0.3),
    FORTY_OFF("四折",0.4),
    FIFTY_OFF("五折",0.5),
    SIXTY_OFF("六折",0.6),
    SEVENTY_OFF("七折",0.7),
    EIGHTY_OFF("八折",0.8),
    NINETY_OFF("九折",0.9);

    private String name;

    private double rate;

    DiscountsEnum(String name,double rate){
        this.name = name;
        this.rate = rate;
    };

    public double getRate() {
        return rate;
    }

    public String getName() {
        return name;
    }

    public static double getRateByName(String name){
        for(DiscountsEnum discountsEnum:DiscountsEnum.values()){
            if(discountsEnum.getName().equalsIgnoreCase(name)){
                return discountsEnum.getRate();
            }
        }
        return -1;
    }
}
